<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script src="./js/03-ajax.js"></script>
  <script>
    // const p1 = new Promise((resolve, reject) => {
    //   reject('rejected')
    // })
    // const p2 = new Promise((resolve, reject) => {
    //   resolve('resolved')
    // })
    // Promise.allSettled([p1, p2]).then(results => {
    //   console.log(results)
    // })
    
    let promises = ['p1'].map(name => {
      return ajax('http://localhost:3000/posts')
    })
    // 始终返回正确
    Promise.allSettled(promises).then(values => {
      console.log(values)
      let users = values.filter(user => {
        return user.status === 'fulfilled'
      })
      console.log(users)
    })
  </script>
</body>
</html>